﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/Main.Master" AutoEventWireup="true"
    CodeBehind="ListaTareas.aspx.cs" Inherits="SistemaWeb.Paginas.Listas.ListaTareas" %>


<asp:Content ID="contenedor" ContentPlaceHolderID="MainContent" runat="server">
    <table id="grid" class="scroll" cellpadding="0" cellspacing="0"></table>
    <div id="pager" class="scroll" style="text-align:center;"></div>
</asp:Content>

<asp:Content ID="scripts" ContentPlaceHolderID="Javascript" runat="server">
<script type="text/javascript">
    jQuery(document).ready(function()
      {
        $("#grid").jqGrid(
        {
            datatype: function()
            {
              $.ajax(
                {
                    url: "ListaTareas.aspx/buscarTareas", //PageMethod
                    data: "{}", //Parametros de entrada del PageMethod                   
                    dataType: "json",
                    type: "post",
                    contentType: "application/json; charset=utf-8",
                    complete: function(jsondata, stat)
                    {
                      if (stat == "success")
                      {
                        jQuery("#grid")[0].addJSONData(JSON.parse
                              (jsondata.responseText).d);
                      }
                      else
                        alert(JSON.parse(jsondata.responseText).Message);
                    }
                });
            },
            jsonReader : //jsonReader –> JQGridJSonResponse data.
            {                
                page: "CurrentPage",
                total: "PageCount",
                records: "RecordCount",
                root: "Items",
                repeatitems: false,
                cell: "Items",
                id: "0"               
            },
            colNames:['Id','Descripcion', 'FechaCreacion'],
   	        colModel:[
   		        {name:'Id',index:'Id', width:55},
   		        {name:'Descripcion',index:'Descripcion', width:90},
   		        {name:'FechaCreacion',index:'FechaCreacion', width:134}	
   	        ],
   	        rowNum:10,
   	        rowList:[10,20,30],
   	        imgpath: "",
   	        pager: jQuery('#pager'),
   	        sortname: 'id',
            viewrecords: true,
            sortorder: "desc",
            caption:"JSON Example"
        }).navGrid('#pager',{edit:true,add:true,del:true});     
              }); 
</script>
</asp:Content>
